import mongoose from '../config/DBHelper'
import moment from 'moment'
const Schema = mongoose.Schema
const UserCollectSchema = new Schema({
  tid: { type: String, ref: 'post' },
  title: {
    type: String
  },
  uid: { type: String, ref: 'user' },
  created: { type: Date }
  // last_sign: { type: Date }
})

UserCollectSchema.pre('save', function (next) {
  this.created = moment().format('YYYY-MM-DD HH:mm:ss')
  next()
})

UserCollectSchema.statics = {
  getCollectList (uid, page, limit) {
    return this.find({ uid }).skip(limit * page).limit(limit)
  }
}

const UserCollects = mongoose.model('user_collects', UserCollectSchema)

export default UserCollects
